#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e5 + 10;
long long arr[N];
long long dp[N];
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> arr[i];
    }
    
    for(int i = 3; i <= n; i++)
    {
        dp[i] = max(dp[i-3] + arr[i-1] , dp[i-1]);
    }
    cout<<dp[n]<<endl;
    
    
    return 0;
}